function e(e, t) {
    if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}

var t = function() {
    function e(e, t) {
        for (var s = 0; s < t.length; s++) {
            var n = t[s];
            n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), 
            Object.defineProperty(e, n.key, n);
        }
    }
    return function(t, s, n) {
        return s && e(t.prototype, s), n && e(t, n), t;
    };
}(), s = function() {
    function s() {
        e(this, s);
    }
    return t(s, [ {
        key: "on",
        value: function(e, t, s) {
            "function" == typeof t ? (this._stores = this._stores || {}, (this._stores[e] = this._stores[e] || []).push({
                cb: t,
                ctx: s
            })) : console.error("listener must be a function");
        }
    }, {
        key: "emit",
        value: function(e) {
            this._stores = this._stores || {};
            var t = this._stores[e], s = void 0;
            if (t) {
                t = t.slice(0), (s = [].slice.call(arguments, 1))[0] = {
                    eventCode: e,
                    data: s[0]
                };
                for (var n = 0, r = t.length; n < r; n++) t[n].cb.apply(t[n].ctx, s);
            }
        }
    }, {
        key: "off",
        value: function(e, t) {
            if (this._stores = this._stores || {}, arguments.length) {
                var s = this._stores[e];
                if (s) if (1 !== arguments.length) {
                    for (var n = 0, r = s.length; n < r; n++) if (s[n].cb === t) {
                        s.splice(n, 1);
                        break;
                    }
                } else delete this._stores[e];
            } else this._stores = {};
        }
    } ]), s;
}();

module.exports = s;